import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/widget/hero.dart';
import 'package:get/get.dart';

class ExtendedImageSlideWidget extends StatefulWidget {
  ExtendedImageSlideWidget({Key? key, required this.url}) : super(key: key);
  final String url;

  @override
  State<ExtendedImageSlideWidget> createState() =>
      _ExtendedImageSlideWidgetState();
}

class _ExtendedImageSlideWidgetState extends State<ExtendedImageSlideWidget> {
  GlobalKey<ExtendedImageSlidePageState> slidePagekey =
      GlobalKey<ExtendedImageSlidePageState>();

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: ExtendedImageSlidePage(
        key: slidePagekey,
        slideAxis: SlideAxis.both,
        slideType: SlideType.onlyImage,
        child: GestureDetector(
          onTap: () {
            slidePagekey.currentState!.popPage();
            Get.back();
          },
          child: Container(
            color: Colors.black,
            child: HeroWidget(
              tag: widget.url,
              slideType: SlideType.onlyImage,
              slidePagekey: slidePagekey,
              child: ExtendedImage.network(
                widget.url,
                enableSlideOutPage: true,
                mode: ExtendedImageMode.gesture,
                initGestureConfigHandler: (state) {
                  return GestureConfig(
                    minScale: 1.0,
                    animationMinScale: 0.6,
                    maxScale: 1.0,
                    animationMaxScale: 3.5,
                    speed: 1.0,
                    inertialSpeed: 100.0,
                    initialScale: 1.0,
                    inPageView: false,
                    initialAlignment: InitialAlignment.center,
                    );
                },
              ),
            ),
          ),
        ),
        
      ),
    );
  }
}
